package com.rms.server.Controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

//@RestController
//@RequestMapping("/sys")
//public class SysController {
//    // 使用Redis
//    @Resource
//    private RedisTemplate<String, Object> redisTemplate;
//    @Value("${_server.CustomizeName.BootTime}")
//    String BootTimeKey;
//
//
//    @GetMapping("/bootTime")
//    public Map getRunTime() {
//        String bootTime = (String) redisTemplate.opsForValue().get(BootTimeKey);
//        HashMap<String, Object> responseInfo = new HashMap<>();
//        HashMap<String, Object> responseData = new HashMap<>();
//        responseData.put("BootTime", bootTime);
//        responseInfo.put("code", 20000);
//        responseInfo.put("msg", "返回系统启动时间");
//        responseInfo.put("data", responseData);
//        return responseInfo;
//    }
//}
@Tag(name = "系统管理", description = "提供系统相关的接口")  // 为控制器添加标签和描述
@RestController
@RequestMapping("/sys")
public class SysController {

    // 使用Redis
    @Resource
    private RedisTemplate<String, Object> redisTemplate;

    @Value("${_server.CustomizeName.BootTime}")
    private String BootTimeKey;

    @Operation(summary = "获取系统启动时间", description = "从 Redis 中获取并返回系统的启动时间")
    @GetMapping("/bootTime")
    public Map<String, Object> getRunTime() {
        String bootTime = (String) redisTemplate.opsForValue().get(BootTimeKey);
        HashMap<String, Object> responseInfo = new HashMap<>();
        HashMap<String, Object> responseData = new HashMap<>();
        responseData.put("BootTime", bootTime);
        responseInfo.put("code", 20000);
        responseInfo.put("msg", "返回系统启动时间");
        responseInfo.put("data", responseData);
        return responseInfo;
    }
}
